<template>
  <div class="shop-coupon-list">
    <div class="nav-bar">
      <div class="title">使用优惠劵</div>
      <i class="van-icon van-icon-cross" @click="isPopop=false"></i>
    </div>
    <div class="coupon-content">
      <van-pull-refresh v-model="isLoading" @refresh="onRefresh" style="height:100%">
        <div class="nodata" v-if="dataList.length===0" style="height:200px;">暂无数据</div>
        <van-list v-model="loading" :finished="finished" :finished-text="dataList.length>7?'没有更多了':''" @load="onLoad" :offset="50" :immediate-check="false">
          <div class="coupon">
            <template v-for="(item,index) in dataList">
              <coupon-list :state="3" :key="index" :item="item" @change="couponChange" />
            </template>
          </div>
        </van-list>
      </van-pull-refresh>
    </div>
  </div>
</template>
<script>
import mixins from '@/utils/mixins';
export default {
  name: 'ShopCoupon',
  data () {
    return {
      isLoading: false,
      paramsUrl: 'list',
      apiType: 'user',
      apiUrl: 'coupon'
    };
  },
  mixins: [mixins],
  props: {
    value: {
      type: Boolean
    }
  },
  created () {
    this.params.status = 0;
    this.getList('coupon', true);
  },
  computed: {
    isPopop: {
      get () {
        return this.value;
      },
      set (value) {
        this.$emit('input', value);
      }
    }
  },
  methods: {
    couponChange (item) {
      this.$emit('change', item);
    }
  }
};
</script>
<style scoped lang="less">
.shop-coupon-list {
  display: flex;
  background-color: #fff;
  height: 100%;
  flex-direction: column;
  .nav-bar {
    line-height: 88px;
    background-color: #fff;
    position: relative;
    .title {
      font-size: 32px;
      text-align: center;
    }
    .van-icon-cross {
      position: absolute;
      top: 28px;
      right: 40px;
      font-size: 32px;
    }
  }
  .coupon-content {
    overflow: auto;
    flex: 1;
    background-color: #f5f5f4;
    padding: 5px 25px 25px;
    .van-pull-refresh__track {
      height: 100%;
    }
  }
}
</style>
